<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>v-for指令</title>
    <script src="../lib/vue_v2.6.14.js"></script>
  </head>
  <body>
    <div id="app">
      <!-- 1、v-for遍历数组 -->
      <ul>
        <li v-for="(item, index) in names" :key="index">{{ index+1 }}----{{ item }}</li>
      </ul>

      <!-- 2、v-for遍历对象 -->
      <ul>
        <li v-for="(val, key) in personInfo" :key="key">{{ key }}----{{ val }}</li>
      </ul>

      <!-- 3、v-for遍历对象数组 -->
      <ul>
        <li v-for="(item, index) in studyList" :key="index">{{ item.title }}</li>
      </ul>
    </div>

    <script>
      const vm = new Vue({
        el: '#app',
        data: {
          names: ['张三', '李四', '王五', '赵六'],
          personInfo: {
            id: 1,
            name: '张三',
            sex: '男',
            age: 28,
            address: '湖南长沙'
          },
          studyList: [
            { id: 1, title: 'Vue' },
            { id: 2, title: 'React' },
            { id: 3, title: 'Angular' }
          ]
        }
      })
    </script>
  </body>
</html>
